home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 787 < prev    next >
Encoding:
Text File  |  1996-08-06  |  2.2 KB  |  59 lines

  1. Path: chronicle.mti.sgi.com!austern
  2. From: jbuck@Synopsys.COM (Joe Buck)
  3. Newsgroups: comp.std.c++
  4. Subject: "swap" and the HP STL implementation
  5. Date: 19 Mar 1996 16:26:07 PST
  6. Organization: Synopsys Inc., Mountain View, CA 94043-4033
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4inc97$e22@hermes.synopsys.com>
  9. NNTP-Posting-Host: isolde.mti.sgi.com
  10. X-Original-Date: 19 Mar 1996 22:25:43 GMT
  11. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  12.     iQBVAwUBMU9Qxky4NqrwXLNJAQEuEAIAhelLRbh1KpC1jgSXRPDLCdtfz+eg3A7d
  13.     mdutwexgRUvo+b9uVsNmhT1A8GbRznpvTVr9UTGKAwLRjejIs39Esw==
  14.     =vf3x
  15. Originator: austern@isolde.mti.sgi.com
  16.  
  17. Many STL containers and standard library objects (e.g. string) provide a
  18. swap function, since it is often much cheaper to exchange two complex
  19. objects directly than to use a temporary.
  20.  
  21. STL also includes iter_swap, for swapping two objects given iterators
  22. to point to them, and in the STL implementation the sort algorithm uses
  23. iter_swap heavily.  But iter_swap doesn't use swap: this means that
  24. things like sorts of vectors of strings are slow.  ObjectSpace copied
  25. HP's implementation, so theirs has the same deficiency.
  26.  
  27. Is there any reason why iter_swap can't be implemented as
  28.  
  29. template <class ForwardIterator1, class ForwardIterator2>
  30. inline void iter_swap(ForwardIterator1 a, ForwardIterator2 b) {
  31.     swap(*a, *b);
  32. }
  33.  
  34. which would gain efficiency in cases where a fast swap exists or could
  35. be provided?
  36.  
  37. Also (to be sure that this is standard-related) would it make sense to
  38. either require, or strongly suggest as a quality-of-implementation
  39. mechanism, that higher-level STL algorithms use lower-level algorithms in
  40. a prescribed way so that if a user implements specializations for some
  41. algorithms, he/she can be assured that the others run faster?
  42.  
  43.  
  44.  
  45.  
  46.  
  47. -- 
  48. -- Joe Buck     <jbuck@synopsys.com>    (not speaking for Synopsys, Inc)
  49.  
  50. Work for something because it is good,
  51. not just because it stands a chance to succeed.       -- Vaclav Havel
  52. ---
  53. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  54.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  55.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  56.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  57.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  58. ]
  59.